package com.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.RoleRightMapper;
import com.mapper.UserMapper;
import com.pojo.SysRight;
import com.pojo.SysRoleRight;
import com.pojo.SysUser;
import com.pojo.Vo.SysUserVo;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, SysUser> implements UserService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    RoleRightMapper roleRightMapper;

//    @Resource
//    UserRepository userRepository;
    @Override
    public SysUserVo login(String usrName, String password) {
        return userMapper.login(usrName, password);
    }

    @Override
    public SysUserVo loginByName(String usrName) {
        return  userMapper.loginByName(usrName);
    }

//    @Override
//    public SysUser getUserByUsrName(String usrName) {
//        return userRepository.findUserByUsrName(usrName);
//    }

    @Override
    public IPage<SysUserVo> getPage(IPage<SysUserVo> page, SysUserVo sysUserVo) {
        return userMapper.getPage(page, sysUserVo);
    }

    @Override
    public List<SysRoleRight> getRightListByRoleId(long roleId) {
        LambdaQueryWrapper<SysRoleRight> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(roleId!=0, SysRoleRight::getRfRoleId,roleId);
        return roleRightMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysRight> getRightByRoleId(long roleId) {
        return null;
    }
}
